<template>
  <!-- 导航按钮 -->
  <div class="box">
    <van-grid :column-num="3">
      <van-grid-item @click="Notice" icon="label" icon-color="#1989fa" text="通知" />
      <van-grid-item @click="Test" icon="todo-list" icon-color="#ff9933" text="考试" />
      <van-grid-item @click="Housework" icon="column" icon-color="#66cc99" text="作业" />

    </van-grid>
  </div>
  <!-- 分割线 -->
  <van-divider content-position="left">学课程</van-divider>
  <!-- 课程推荐 -->
  <div class="films" ref="filmsBox">
  <div class="item" @click="courseDetail(item.id)" v-for="(item, index) in courseList" :key="index">
              <div class="left">
                  <img :src="item.courseCover" />
              </div>
              <div class="middle">
                  <div>{{ item.courseName }}</div>
                  <!-- <div>
                    <span>讲师：</span>
                    <span>{{ item.createUser }}</span>
                </div> -->
                  <div>更新人：{{ item.updateUser }}</div>
                  <!-- <div>{{ item.createTime }}</div> -->
              </div>
              <div class="right">
                  <span>参与</span>
              </div>
          </div>
          </div>
</template>
    
    
<script setup lang='ts'>
import { onMounted, ref } from 'vue';
// 导入“数据列表”组件
import NoticeList from './NoticeList.vue';
import { getCourse } from '../api/api'
import { useRouter } from 'vue-router';
import { useStore } from 'vuex';

// import images from "../assets/images/"
//  刷新
let loadingTag = ref<boolean>(true);
let imageError = new URL("../assets/images/imageError.jpg", import.meta.url).href
const router = useRouter()
const courseDetail = (courseId: any) => {
  // 进行路由跳转
  router.push({ path: "/courseDetail/courseWare", query: { params: courseId } })
};
const courseList = ref<any>([])

onMounted(async () => {
  const datas = {}
  const rea = await getCourse(datas);
  console.log(rea);

  if (rea.data.code === 0) {
    courseList.value.push(...rea.data.data.data)
    console.log(courseList.value,"111");
    
    
  } else {
    return false
  }

});
// 通知栏页面
const Notice = () => {
  router.push("/notice/")
}
// 考试列表页面
const Test = () => {
  router.push('/test/')
}
// 作业栏页面
const Housework = () => {
  router.push('/housework/')
}

</script>
    
<style scoped lang='scss'>
.box{
  
  // --van-grid-item-content-background:dodgerblue0
}

.films {
    padding-bottom: 60px;
    padding-top: 0;

    .item {
        margin-top: 15px;
        padding-bottom: 10px;
        padding-top: 10px;
        display: flex;
        color: #797d82;
        font-size: 13px;
        border-bottom: 1px solid #e7d8d8;
        background-color: #fff;

        .left {
            width: 100px;
            height: 70px;
            margin-left: 20px;

            img {
                width: 90px;
                height: 70px;
            }
        }

        .middle {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            width: 50%;
            margin-left: 10px;

            div:nth-of-type(1) {
                color: #191a1b;
                font-size: 16px;
            }

            div:nth-of-type(3) {
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
        }

        .right {
            width: 20%;
            display: flex;
            align-items: center;
            margin-right: 10px;

            span {
                border: 1px solid rgb(108, 244, 106);
                background: rgb(108, 244, 106);
                color: #fff;
                border-radius: 10px;
                height: 25px;
                line-height: 25px;
                font-size: 13px;
                width: 50px;
                text-align: center;
            }
        }
    }
}
</style>